home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000106_icon-group-sender _Thu Oct 30 08:36:03 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  5KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id IAA25711
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Thu, 30 Oct 1997 08:36:03 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA28663; Thu, 30 Oct 1997 08:36:02 -0700
  7. To: icon-group@optima.CS.Arizona.EDU
  8. Date: Thu, 30 Oct 1997 16:27:31 +1000
  9. From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
  10. Message-Id: <Stuart.Robinson-3010971627320001@asianstmg-229.anu.edu.au>
  11. Organization: ANU
  12. Sender: icon-group-request@optima.CS.Arizona.EDU
  13. Subject: problem with data type in program
  14. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  15. Status: RO
  16.  
  17. Hello, everyone.  I wanted to apologise for causing a stir with my last
  18. couple of postings.  It has been brought to my attention that they gave
  19. the impression of not only an unwillingnes to actually learn Icon but also
  20. ingratitude towards those who have helped me in the past.  This is not the
  21. impression that I wish to give the readers of this newsgroup, because I am
  22. keen to learn to program well in Icon and I sincerely appreciate all of
  23. the help that I have received thus far.
  24.  
  25. With that said, I would like to solicit help with a program that is
  26. causing me problems.  It is, I think, less trivial than my query about
  27. tabulating values (which was admittedly trivial and should not have been
  28. posted in the first place).  
  29.  
  30. The problem is this.  I am getting error messages saying that the main
  31. procedure expects a table does not get one from the procedure it
  32. invokes--namely, scantext(). But it looks to me as if the value returned
  33. by scantext() should be a table.  What am I doing wrong?
  34.  
  35. Thanks in advance for any help.
  36.  
  37. Regards,
  38. Stuart Robinson
  39.  
  40.  
  41.  
  42. ############################################################################
  43. #
  44. #       File:     tabulate_AO_person.icn
  45. #       Subject:  Program to tabulate person of A and O
  46. #       Author:   Stuart P. Robinson
  47. #       Date:     14 October, 1997
  48. #
  49. ############################################################################
  50. #
  51. #  This program was written to calculate what proportion of A's and O's 
  52. #  are 1st, 2nd, or 3rd person. Unlike previous version, it does NOT give 
  53. #  percentages--just raw numbers. The 7 logical possibilities it counts are:
  54. #  
  55. #     1.    1-2         first_on_second
  56. #     2.    1-3         first_on_third
  57. #     3.    2-1         second_on_first
  58. #     4.    2-3         second_on_third
  59. #     5.    3-1         third_on_first
  60. #     6.    3-2         third_on_second
  61. #     7.    3-3         third_on_third
  62. #
  63. ############################################################################
  64.  
  65. procedure main()
  66.    output := sort( scan_text(), 1 )
  67.    write( "Person Config." || "/t" || "No." )
  68.    every x := key( output ) do
  69.       write( x || "\t" || output[x] )
  70. end
  71.  
  72.  
  73.  
  74. procedure scan_text( )
  75.    value_table := table( 0 )
  76.  
  77.    while line := read()
  78.    do
  79.       {
  80.       line ?
  81.          {
  82.          value_table[ search_line() ] +:= 1
  83.          }
  84.       }
  85.  
  86. return value_table
  87. end
  88.  
  89.  
  90.  
  91. procedure search_line( )
  92.    chars := &letters++&digits++'{`'
  93.    subject := 0
  94.    object := 0
  95.  
  96.    if find( "{Q" ) then
  97.       while tab( upto( chars ) ) do 
  98.          {
  99.          word := tab( many( chars ) )
  100.          word ?
  101.             {
  102.             if tab( find( "{" ) ) then
  103.                word := tab( 0 )
  104.                case word of
  105.                   {
  106.                   "{A1" :  subject := 1
  107.                   "{A2" :  subject := 2
  108.                   "{A"  :  subject := 3
  109.  
  110.                   "{O1" :  object := 1
  111.                   "{O2" :  object := 2
  112.                   "{O"  :  object := 3
  113.                   }
  114.                }
  115.             }
  116.  
  117.    if subject == 1 then
  118.       if object == 2 then type := "first on second"
  119.       else if object == 3 then type := "first on third"
  120.  
  121.    if subject == 2 then 
  122.       if object == 1 then type := "second on first"
  123.       else if object == 3 then type := "second on third"
  124.  
  125.    if subject == 3 then
  126.       if object == 1 then type := "third on first"
  127.       else if object == 2 then type := "third on second"
  128.       else if object == 3 then type := "third on third"
  129.  
  130. return type
  131. end
  132.  
  133. -- 
  134. Stuart Robinson <Stuart.Robinson@nospam.anu.edu.au>
  135. The Australian National University
  136. *TO REPLY, REMOVE "nospam." FROM E-MAIL ADDRESS GIVEN ABOVE
  137.